<!DOCTYPE html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">
<meta name="theme-color" content="#222">

<script>
    (function(){
        if(''){
            if (prompt('请输入文章密码') !== ''){
                alert('密码错误！');
                history.back();
            }
        }
    })();
</script>








<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">






  <script>
  (function(i,s,o,g,r,a,m){i["DaoVoiceObject"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;a.charset="utf-8";m.parentNode.insertBefore(a,m)})(window,document,"script",('https:' == document.location.protocol ? 'https:' : 'http:') + "//widget.daovoice.io/widget/6f697dad.js","daovoice")
  daovoice('init', {
      app_id: "6f697dad"
    });
  daovoice('update');
  </script>















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon.ico?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Android开发工程师文集,">





  <link rel="alternate" href="/atom.xml" title="达叔小生" type="application/atom+xml">






<meta name="description" content="前言大家好，我是 Vic，今天给大家带来Android开发工程师文集-1 小时学会SQLite的概述，希望你们喜欢 内容 什么是Sqlite：效率高，开源，小型，程序驱动，支持事务操作，无数据类型，可嵌入的关系型数据库独立的，跨平台的，代码量少，简单易用  创建表语句1create table student(_id Integer primary key, name varchar(10), a">
<meta name="keywords" content="Android开发工程师文集">
<meta property="og:type" content="article">
<meta property="og:title" content="Android开发工程师文集-1 小时学会SQLite">
<meta property="og:url" content="https://huangguangda.github.io/2018/03/16/1/index.html">
<meta property="og:site_name" content="达叔小生">
<meta property="og:description" content="前言大家好，我是 Vic，今天给大家带来Android开发工程师文集-1 小时学会SQLite的概述，希望你们喜欢 内容 什么是Sqlite：效率高，开源，小型，程序驱动，支持事务操作，无数据类型，可嵌入的关系型数据库独立的，跨平台的，代码量少，简单易用  创建表语句1create table student(_id Integer primary key, name varchar(10), a">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2018-04-09T09:15:28.818Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Android开发工程师文集-1 小时学会SQLite">
<meta name="twitter:description" content="前言大家好，我是 Vic，今天给大家带来Android开发工程师文集-1 小时学会SQLite的概述，希望你们喜欢 内容 什么是Sqlite：效率高，开源，小型，程序驱动，支持事务操作，无数据类型，可嵌入的关系型数据库独立的，跨平台的，代码量少，简单易用  创建表语句1create table student(_id Integer primary key, name varchar(10), a">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":true,"onmobile":true},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://huangguangda.github.io/2018/03/16/1/">




<!-- 网页加载条 -->
<script src="https://neveryu.github.io/js/src/pace.min.js"></script>
  <title>Android开发工程师文集-1 小时学会SQLite | 达叔小生</title>
  









  <!-- 音频播放 -->
<link rel="stylesheet" href="/dist/APlayer.min.css">
<div id="aplayer"></div>
<script type="text/javascript" src="/dist/APlayer.min.js"></script>
<script type="text/javascript" src="/dist/music.js"></script>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <a href="https://github.com/huangguangda" class="github-corner" aria-label="View source on Github"><svg width="80" height="80" viewbox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">达叔小生</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <h1 class="site-subtitle" itemprop="description">爱好分享的码农</h1>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-首页">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-关于">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-标签">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-分类">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-归档">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-书籍">
          <a href="/books" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-book"></i> <br>
            
            书籍
          </a>
        </li>
      
        
        <li class="menu-item menu-item-电影">
          <a href="/movies" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-chrome"></i> <br>
            
            电影
          </a>
        </li>
      
        
        <li class="menu-item menu-item-站点">
          <a href="/sitemap.xml" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-sitemap"></i> <br>
            
            站点
          </a>
        </li>
      
        
        <li class="menu-item menu-item-公益">
          <a href="/404/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br>
            
            公益
          </a>
        </li>
      
        
        <li class="menu-item menu-item-课本">
          <a href="/book/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-apple"></i> <br>
            
            课本
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br>
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off" placeholder="搜索..." spellcheck="false" type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>


 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://huangguangda.github.io/2018/03/16/1/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="达叔小生">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="达叔小生">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">Android开发工程师文集-1 小时学会SQLite</h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-03-16T15:03:52+08:00">
                2018-03-16
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Android开发工程师文集/" itemprop="url" rel="index">
                    <span itemprop="name">Android开发工程师文集</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv">本文总阅读量
            <span class="busuanzi-value" id="busuanzi_value_page_pv"></span>次
            </span>
          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  2,717
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  16
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p>大家好，我是 <code>Vic</code>，今天给大家带来<code>Android开发工程师文集-1 小时学会SQLite</code>的概述，希望你们喜欢</p>
<h2 id="内容"><a href="#内容" class="headerlink" title="内容"></a>内容</h2><ul>
<li>什么是Sqlite：<br>效率高，开源，小型，程序驱动，支持事务操作，无数据类型，可嵌入的关系型数据库<br>独立的，跨平台的，代码量少，简单易用</li>
</ul>
<p><strong>创建表语句</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">create table student(_id Integer primary key, name varchar(10), age Integer not null);</span><br></pre></td></tr></table></figure></p>
<p><strong>删除表</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">drop table student;</span><br></pre></td></tr></table></figure></p>
<p><strong>插入数据</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">Insert into 表名(字段列表) values (值列表);</span><br><span class="line">insert into student(_id,age) values(1,17);</span><br><span class="line">insert into student values(1,&quot;vic&quot;,17);</span><br></pre></td></tr></table></figure></p>
<p><strong>修改数据</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">update student set name=&quot;vic&quot;,age=17 where _id=1;</span><br></pre></td></tr></table></figure></p>
<p><strong>更新数据</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Update 表名 set 字段=值 列表 更新的条件</span><br></pre></td></tr></table></figure></p>
<p><strong>删除数据</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">delete from 表名 [删除条件];</span><br><span class="line">delete from student where _id=1;</span><br></pre></td></tr></table></figure></p>
<p><strong>查询语句</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">select 字段名 from 表名称 [查询条件];</span><br><span class="line">select 列名称 from 表名称 where 条件;</span><br><span class="line">group by 分组的字段 having 筛选条件 order by 排序字段;</span><br><span class="line">select * from student;</span><br><span class="line">select _id from student;</span><br><span class="line">select * from student where _id=1;</span><br><span class="line">select * from student where _id=1 and age&gt;17;</span><br><span class="line">select * from student where age like &quot;%1%&quot;;</span><br><span class="line">select * from student where age&gt;17 order by _id=1;</span><br></pre></td></tr></table></figure></p>
<h2 id="内容-1"><a href="#内容-1" class="headerlink" title="内容"></a>内容</h2><ul>
<li>创建数据库</li>
<li>实现数据库中的增删改查</li>
</ul>
<h2 id="要点"><a href="#要点" class="headerlink" title="要点"></a>要点</h2><p><code>SQLiteOpenHelper</code>,<code>onCreate()</code>,<code>onUpgrade()</code>,<code>onOpen()</code><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span><br><span class="line">&lt;LinearLayout</span><br><span class="line"> xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;</span><br><span class="line">    android:layout_width=&quot;match_parent&quot;</span><br><span class="line">    android:layout_height=&quot;match_parent&quot;</span><br><span class="line">    android:background=&quot;@drawable/login_bg&quot;</span><br><span class="line">    android:orientation=&quot;vertical&quot;&gt;</span><br><span class="line"> &lt;Button</span><br><span class="line">  android:layout_width=&quot;wrap_content&quot;</span><br><span class="line">  android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">  android:text=&quot;创建&quot;</span><br><span class="line">  android:onClick=&quot;create&quot;</span><br><span class="line">  android:background=&quot;#000000&quot;/&gt;</span><br><span class="line">&lt;/LinearLayout&gt;</span><br></pre></td></tr></table></figure></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">//MainActivity.java</span><br><span class="line">public class MainActivity extends AppCompatActivity &#123;</span><br><span class="line">  private MySqliteHelper helper;</span><br><span class="line"> @Override</span><br><span class="line"> protected void onCreate(Bundle savedInstanceState)&#123;</span><br><span class="line"> super.onCreate(savedInstanceState);</span><br><span class="line"> setContentView(R.layout.activity_main);</span><br><span class="line"> helper = DbManger.getIntance(this);</span><br><span class="line"> &#125;</span><br><span class="line"> public void createdb(View view)&#123;</span><br><span class="line">  SQLiteDatabase db=helper.getWritableDatable();</span><br><span class="line"> &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">//创建一个类</span><br><span class="line">//sqliteOpenHelper</span><br><span class="line">//提供了onCreate()和onUpgrade()与onOpen()</span><br><span class="line">public class MySqliteHelper extends SQLiteOpenHelper&#123;</span><br><span class="line"> public MySqliteHelper(Context context, String name, SQLitebase.CursorFactory factory, int version)&#123;</span><br><span class="line"> super(context,name,factory,version);</span><br><span class="line"> &#125;</span><br><span class="line"> public MySqliteHelper(Context context)&#123;</span><br><span class="line">  super(context,Constant.DATABASE_NAME,null,Constant.DATABASE_VERSION);</span><br><span class="line">&#125;</span><br><span class="line"> //数据库创建时回调</span><br><span class="line"> @Override</span><br><span class="line"> public void onCreate(SQLiteDatabase db)&#123;</span><br><span class="line">  Log.i(&quot;tag&quot;,&quot;--onCreate--&quot;);</span><br><span class="line">  //String sql=&quot;create table student(_id Integer primary key,name verchar(10),age Integer)&quot;;</span><br><span class="line">  String sql = &quot;create table &quot;+Constant.TABLE_NAME+&quot;(&quot;+Constant._ID+&quot; Integer primary key,&quot;+Constant.NAME+&quot; varchar(10),&quot;+Constant.AGE+&quot; Integer)&quot;;</span><br><span class="line">  db.execSQL(sql);//执行数据库语句</span><br><span class="line"> &#125;</span><br><span class="line"> //数据库更新</span><br><span class="line"> @Override</span><br><span class="line"> public void onUpgrade(SQLiteDatabase db,int oldVersion, int newVersion)&#123;</span><br><span class="line">  Log.i(&quot;tag&quot;,&quot;--onUpgrade--&quot;);</span><br><span class="line"> &#125;</span><br><span class="line"> //数据库打开</span><br><span class="line"> @Override</span><br><span class="line"> public void onOpen(SQLiteDatabase db)&#123;</span><br><span class="line">  super.onOpen(db);</span><br><span class="line">  Log.i(&quot;tag&quot;,&quot;--onOpen--&quot;);</span><br><span class="line"> &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">//创建库表</span><br><span class="line">public class Contant&#123;</span><br><span class="line"> public static final String DATABASE_NAME=“info.db”;//数据库名称</span><br><span class="line"> public static final int DATABASE_VERSION=1;//数据库的版本号</span><br><span class="line"> public static final String TABLE_NAME=&quot;student&quot;;//表名</span><br><span class="line">  //用这里表示</span><br><span class="line"> public static final String _ID=&quot;_id&quot;;</span><br><span class="line"> public static final String _NAME=&quot;name&quot;;</span><br><span class="line"> public static final String AGE=&quot;age&quot;;</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">public class DbManger&#123;</span><br><span class="line"> private static MySqliteHelper helper;</span><br><span class="line"> public static MySqliteHelper getIntance(Context context)&#123;</span><br><span class="line">   if(helper == null)&#123;</span><br><span class="line">     helper=new MySqliteHelper(content);</span><br><span class="line">   &#125;</span><br><span class="line">   return hepler;</span><br><span class="line"> &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span><br><span class="line">&lt;LinearLayout</span><br><span class="line"> xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;</span><br><span class="line">    android:layout_width=&quot;match_parent&quot;</span><br><span class="line">    android:layout_height=&quot;match_parent&quot;</span><br><span class="line">    android:background=&quot;@drawable/login_bg&quot;</span><br><span class="line">    android:orientation=&quot;vertical&quot;&gt;</span><br><span class="line"> &lt;Button</span><br><span class="line">  android:layout_width=&quot;wrap_content&quot;</span><br><span class="line">  android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">  android:text=&quot;创建&quot;</span><br><span class="line">  android:onClick=&quot;create&quot;</span><br><span class="line">  android:background=&quot;#000000&quot;/&gt;</span><br><span class="line">&lt;Button</span><br><span class="line">  android:id=&quot;@+id/btn_insert&quot;</span><br><span class="line">  android:layout_width=&quot;wrap_content&quot;</span><br><span class="line">  android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">  android:text=&quot;插入数据&quot;</span><br><span class="line">  android:onClick=&quot;click&quot;</span><br><span class="line">  android:layout_marginTop=&quot;15dp&quot;</span><br><span class="line">  android:background=&quot;#000000&quot;/&gt;</span><br><span class="line">&lt;/LinearLayout&gt;</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">//MainActivity.java</span><br><span class="line">public class MainActivity extends AppCompatActivity &#123;</span><br><span class="line">  private MySqliteHelper helper;</span><br><span class="line"> @Override</span><br><span class="line"> protected void onCreate(Bundle savedInstanceState)&#123;</span><br><span class="line"> super.onCreate(savedInstanceState);</span><br><span class="line"> setContentView(R.layout.activity_main);</span><br><span class="line"> helper = DbManger.getIntance(this);</span><br><span class="line"> &#125;</span><br><span class="line"> public void createdb(View view)&#123;</span><br><span class="line">  SQLiteDatabase db=helper.getWritableDatable();</span><br><span class="line"> &#125;</span><br><span class="line"> public void click(View view)&#123;</span><br><span class="line">  switch(view.getId())&#123;</span><br><span class="line">   case R.id.btn_insert:</span><br><span class="line">    SQLiteDatabase db=helper.getWritableDatabase();</span><br><span class="line">    String sql=&quot;insert into &quot;+Constant.TABLE_NAME+&quot; values(1,&apos;vic&apos;,17)&quot;;</span><br><span class="line">    DbManger.execSQL(db,sql);</span><br><span class="line">    String sql2=&quot;insert into &quot;+Constant.TABLE_NAME+&quot; values(2,&apos;vic&apos;,23)&quot;;</span><br><span class="line">    DbManger.execSQL(db,sql2);</span><br><span class="line">    db.close();</span><br><span class="line">    break;</span><br><span class="line"> &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">public class DbManger&#123;</span><br><span class="line"> private static MySqliteHelper helper;</span><br><span class="line"> public static MySqliteHelper getIntance(Context context)&#123;</span><br><span class="line">   if(helper == null)&#123;</span><br><span class="line">     helper=new MySqliteHelper(content);</span><br><span class="line">   &#125;</span><br><span class="line">   return hepler;</span><br><span class="line"> &#125;</span><br><span class="line"> public static void execSQL(SQLiteDatabase db,String sql)&#123;</span><br><span class="line">  if(db!=null)&#123;</span><br><span class="line">   if(sql!=null &amp;&amp; !&quot;&quot;.equals(sql))&#123;</span><br><span class="line">     db.execSQL(sql);</span><br><span class="line">  &#125;</span><br><span class="line"> &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span><br><span class="line">&lt;LinearLayout</span><br><span class="line"> xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;</span><br><span class="line">    android:layout_width=&quot;match_parent&quot;</span><br><span class="line">    android:layout_height=&quot;match_parent&quot;</span><br><span class="line">    android:background=&quot;@drawable/login_bg&quot;</span><br><span class="line">    android:orientation=&quot;vertical&quot;&gt;</span><br><span class="line"> &lt;Button</span><br><span class="line">  android:layout_width=&quot;wrap_content&quot;</span><br><span class="line">  android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">  android:text=&quot;创建&quot;</span><br><span class="line">  android:onClick=&quot;create&quot;</span><br><span class="line">  android:background=&quot;#000000&quot;/&gt;</span><br><span class="line">&lt;Button</span><br><span class="line">  android:id=&quot;@+id/btn_insert&quot;</span><br><span class="line">  android:layout_width=&quot;wrap_content&quot;</span><br><span class="line">  android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">  android:text=&quot;插入数据&quot;</span><br><span class="line">  android:onClick=&quot;click&quot;</span><br><span class="line">  android:layout_marginTop=&quot;15dp&quot;</span><br><span class="line">  android:background=&quot;#000000&quot;/&gt;</span><br><span class="line">&lt;Button</span><br><span class="line">  android:id=&quot;@+id/btn_update&quot;</span><br><span class="line">  android:layout_width=&quot;wrap_content&quot;</span><br><span class="line">  android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">  android:text=&quot;修改数据&quot;</span><br><span class="line">  android:onClick=&quot;click&quot;</span><br><span class="line">  android:layout_marginTop=&quot;15dp&quot;</span><br><span class="line">  android:background=&quot;#000000&quot;/&gt;</span><br><span class="line">&lt;/LinearLayout&gt;</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">//MainActivity.java</span><br><span class="line">public class MainActivity extends AppCompatActivity &#123;</span><br><span class="line">  private MySqliteHelper helper;</span><br><span class="line"> @Override</span><br><span class="line"> protected void onCreate(Bundle savedInstanceState)&#123;</span><br><span class="line"> super.onCreate(savedInstanceState);</span><br><span class="line"> setContentView(R.layout.activity_main);</span><br><span class="line"> helper = DbManger.getIntance(this);</span><br><span class="line"> &#125;</span><br><span class="line"> public void createdb(View view)&#123;</span><br><span class="line">  SQLiteDatabase db=helper.getWritableDatable();</span><br><span class="line"> &#125;</span><br><span class="line"> public void click(View view)&#123;</span><br><span class="line">  switch(view.getId())&#123;</span><br><span class="line">   case R.id.btn_insert:</span><br><span class="line">    SQLiteDatabase db=helper.getWritableDatabase();</span><br><span class="line">    String sql=&quot;insert into &quot;+Constant.TABLE_NAME+&quot; values(1,&apos;vic&apos;,17)&quot;;</span><br><span class="line">    DbManger.execSQL(db,sql);</span><br><span class="line">    String sql2=&quot;insert into &quot;+Constant.TABLE_NAME+&quot; values(2,&apos;vic&apos;,23)&quot;;</span><br><span class="line">    DbManger.execSQL(db,sql2);</span><br><span class="line">    db.close();</span><br><span class="line">    break;</span><br><span class="line">   case R.id.btn_update:</span><br><span class="line">    db=helper.getWritableDatabase();</span><br><span class="line">    String updateSql=&quot;update &quot;+Constant.TABLE_NAME&quot;+&quot; set &quot;+Contant.NAME+&quot;=&apos;vic2&apos; where &quot;+Contant._ID+&quot;=1&quot;;</span><br><span class="line">    DbManger.execSQL(db,updateSql);</span><br><span class="line">    db.close();</span><br><span class="line">    break;</span><br><span class="line"> &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span><br><span class="line">&lt;LinearLayout</span><br><span class="line"> xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;</span><br><span class="line">    android:layout_width=&quot;match_parent&quot;</span><br><span class="line">    android:layout_height=&quot;match_parent&quot;</span><br><span class="line">    android:background=&quot;@drawable/login_bg&quot;</span><br><span class="line">    android:orientation=&quot;vertical&quot;&gt;</span><br><span class="line"> &lt;Button</span><br><span class="line">  android:layout_width=&quot;wrap_content&quot;</span><br><span class="line">  android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">  android:text=&quot;创建&quot;</span><br><span class="line">  android:onClick=&quot;create&quot;</span><br><span class="line">  android:background=&quot;#000000&quot;/&gt;</span><br><span class="line">&lt;Button</span><br><span class="line">  android:id=&quot;@+id/btn_insert&quot;</span><br><span class="line">  android:layout_width=&quot;wrap_content&quot;</span><br><span class="line">  android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">  android:text=&quot;插入数据&quot;</span><br><span class="line">  android:onClick=&quot;click&quot;</span><br><span class="line">  android:layout_marginTop=&quot;15dp&quot;</span><br><span class="line">  android:background=&quot;#000000&quot;/&gt;</span><br><span class="line">&lt;Button</span><br><span class="line">  android:id=&quot;@+id/btn_update&quot;</span><br><span class="line">  android:layout_width=&quot;wrap_content&quot;</span><br><span class="line">  android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">  android:text=&quot;修改数据&quot;</span><br><span class="line">  android:onClick=&quot;click&quot;</span><br><span class="line">  android:layout_marginTop=&quot;15dp&quot;</span><br><span class="line">  android:background=&quot;#000000&quot;/&gt;</span><br><span class="line">&lt;Button</span><br><span class="line">  android:id=&quot;@+id/btn_delete&quot;</span><br><span class="line">  android:layout_width=&quot;wrap_content&quot;</span><br><span class="line">  android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">  android:text=&quot;删除数据&quot;</span><br><span class="line">  android:onClick=&quot;click&quot;</span><br><span class="line">  android:layout_marginTop=&quot;15dp&quot;</span><br><span class="line">  android:background=&quot;#000000&quot;/&gt;</span><br><span class="line">&lt;/LinearLayout&gt;</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line">//MainActivity.java</span><br><span class="line">public class MainActivity extends AppCompatActivity &#123;</span><br><span class="line">  private MySqliteHelper helper;</span><br><span class="line"> @Override</span><br><span class="line"> protected void onCreate(Bundle savedInstanceState)&#123;</span><br><span class="line"> super.onCreate(savedInstanceState);</span><br><span class="line"> setContentView(R.layout.activity_main);</span><br><span class="line"> helper = DbManger.getIntance(this);</span><br><span class="line"> &#125;</span><br><span class="line"> public void createdb(View view)&#123;</span><br><span class="line">  SQLiteDatabase db=helper.getWritableDatable();</span><br><span class="line"> &#125;</span><br><span class="line"> public void click(View view)&#123;</span><br><span class="line">  switch(view.getId())&#123;</span><br><span class="line">   case R.id.btn_insert:</span><br><span class="line">    SQLiteDatabase db=helper.getWritableDatabase();</span><br><span class="line">    String sql=&quot;insert into &quot;+Constant.TABLE_NAME+&quot; values(1,&apos;vic&apos;,17)&quot;;</span><br><span class="line">    DbManger.execSQL(db,sql);</span><br><span class="line">    String sql2=&quot;insert into &quot;+Constant.TABLE_NAME+&quot; values(2,&apos;vic&apos;,23)&quot;;</span><br><span class="line">    DbManger.execSQL(db,sql2);</span><br><span class="line">    db.close();</span><br><span class="line">    break;</span><br><span class="line">   case R.id.btn_update:</span><br><span class="line">    db=helper.getWritableDatabase();</span><br><span class="line">    String updateSql=&quot;update &quot;+Constant.TABLE_NAME&quot;+&quot; set &quot;+Contant.NAME+&quot;=&apos;vic2&apos; where &quot;+Contant._ID+&quot;=1&quot;;</span><br><span class="line">    DbManger.execSQL(db,updateSql);</span><br><span class="line">    db.close();</span><br><span class="line">    break;</span><br><span class="line">   case R.id.btn_delete:</span><br><span class="line">    db=helper.getWritableDatabase();</span><br><span class="line">    String delSql=&quot;delete from &quot;+Constant.TABLE_NAME+&quot; where &quot;+Constant._ID+&quot;=2&quot;;</span><br><span class="line">    DbManger.execSQL(db,delSql);</span><br><span class="line">    db.close();</span><br><span class="line">    break;</span><br><span class="line"> &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br></pre></td><td class="code"><pre><span class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span><br><span class="line">&lt;LinearLayout</span><br><span class="line"> xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;</span><br><span class="line">    android:layout_width=&quot;match_parent&quot;</span><br><span class="line">    android:layout_height=&quot;match_parent&quot;</span><br><span class="line">    android:background=&quot;@drawable/login_bg&quot;</span><br><span class="line">    android:orientation=&quot;vertical&quot;&gt;</span><br><span class="line"> &lt;Button</span><br><span class="line">  android:layout_width=&quot;wrap_content&quot;</span><br><span class="line">  android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">  android:text=&quot;创建&quot;</span><br><span class="line">  android:onClick=&quot;create&quot;</span><br><span class="line">  android:background=&quot;#000000&quot;/&gt;</span><br><span class="line">&lt;Button</span><br><span class="line">  android:id=&quot;@+id/btn_insert&quot;</span><br><span class="line">  android:layout_width=&quot;wrap_content&quot;</span><br><span class="line">  android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">  android:text=&quot;插入数据&quot;</span><br><span class="line">  android:onClick=&quot;click&quot;</span><br><span class="line">  android:layout_marginTop=&quot;15dp&quot;</span><br><span class="line">  android:background=&quot;#000000&quot;/&gt;</span><br><span class="line">&lt;Button</span><br><span class="line">  android:id=&quot;@+id/btn_update&quot;</span><br><span class="line">  android:layout_width=&quot;wrap_content&quot;</span><br><span class="line">  android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">  android:text=&quot;修改数据&quot;</span><br><span class="line">  android:onClick=&quot;click&quot;</span><br><span class="line">  android:layout_marginTop=&quot;15dp&quot;</span><br><span class="line">  android:background=&quot;#000000&quot;/&gt;</span><br><span class="line">&lt;Button</span><br><span class="line">  android:id=&quot;@+id/btn_delete&quot;</span><br><span class="line">  android:layout_width=&quot;wrap_content&quot;</span><br><span class="line">  android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">  android:text=&quot;删除数据&quot;</span><br><span class="line">  android:onClick=&quot;click&quot;</span><br><span class="line">  android:layout_marginTop=&quot;15dp&quot;</span><br><span class="line">  android:background=&quot;#000000&quot;/&gt;</span><br><span class="line">&lt;Button</span><br><span class="line">  android:id=&quot;@+id/btn_insertApi&quot;</span><br><span class="line">  android:layout_width=&quot;wrap_content&quot;</span><br><span class="line">  android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">  android:text=&quot;插入数据&quot;</span><br><span class="line">  android:onClick=&quot;onclick&quot;</span><br><span class="line">  android:layout_marginTop=&quot;15dp&quot;</span><br><span class="line">  android:background=&quot;#000000&quot;/&gt;</span><br><span class="line">&lt;/LinearLayout&gt;</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br></pre></td><td class="code"><pre><span class="line">//MainActivity.java</span><br><span class="line">public class MainActivity extends AppCompatActivity &#123;</span><br><span class="line">  private MySqliteHelper helper;</span><br><span class="line"> @Override</span><br><span class="line"> protected void onCreate(Bundle savedInstanceState)&#123;</span><br><span class="line"> super.onCreate(savedInstanceState);</span><br><span class="line"> setContentView(R.layout.activity_main);</span><br><span class="line"> helper = DbManger.getIntance(this);</span><br><span class="line"> &#125;</span><br><span class="line"> public void createdb(View view)&#123;</span><br><span class="line">  SQLiteDatabase db=helper.getWritableDatable();</span><br><span class="line"> &#125;</span><br><span class="line"> public void onClick(View view)&#123;</span><br><span class="line">  switch(view.getId())&#123;</span><br><span class="line">   case R.id.btn_insertApi:</span><br><span class="line">    SQLiteDatabase db=helper.getWritableDatabase();</span><br><span class="line">    ContentValues values=new ContentValues();</span><br><span class="line">    values.put(Constant._ID,3);</span><br><span class="line">    values.put(Constant.NAME,&quot;vic&quot;);</span><br><span class="line">    values.put(Constant.AGE,17);</span><br><span class="line">    long result=db.insert(Constant.TABLE_NAME,null,values);</span><br><span class="line">    if(result&gt;0)&#123;</span><br><span class="line">     Toast.makeText(MainActivity.this,&quot;插入数据成功!&quot;,Toast.LENGTH_LONG).show();</span><br><span class="line">    &#125;else&#123;</span><br><span class="line">      Toast.makeText(MainActivity.this,&quot;插入数据失败!&quot;,Toast.LENGTH_LONG).show();</span><br><span class="line">    &#125;</span><br><span class="line">    db.close();</span><br><span class="line">    break;</span><br><span class="line">   &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"> public void click(View view)&#123;</span><br><span class="line">  switch(view.getId())&#123;</span><br><span class="line">   case R.id.btn_insert:</span><br><span class="line">    SQLiteDatabase db=helper.getWritableDatabase();</span><br><span class="line">    String sql=&quot;insert into &quot;+Constant.TABLE_NAME+&quot; values(1,&apos;vic&apos;,17)&quot;;</span><br><span class="line">    DbManger.execSQL(db,sql);</span><br><span class="line">    String sql2=&quot;insert into &quot;+Constant.TABLE_NAME+&quot; values(2,&apos;vic&apos;,23)&quot;;</span><br><span class="line">    DbManger.execSQL(db,sql2);</span><br><span class="line">    db.close();</span><br><span class="line">    break;</span><br><span class="line">   case R.id.btn_update:</span><br><span class="line">    db=helper.getWritableDatabase();</span><br><span class="line">    String updateSql=&quot;update &quot;+Constant.TABLE_NAME&quot;+&quot; set &quot;+Contant.NAME+&quot;=&apos;vic2&apos; where &quot;+Contant._ID+&quot;=1&quot;;</span><br><span class="line">    DbManger.execSQL(db,updateSql);</span><br><span class="line">    db.close();</span><br><span class="line">    break;</span><br><span class="line">   case R.id.btn_delete:</span><br><span class="line">    db=helper.getWritableDatabase();</span><br><span class="line">    String delSql=&quot;delete from &quot;+Constant.TABLE_NAME+&quot; where &quot;+Constant._ID+&quot;=2&quot;;</span><br><span class="line">    DbManger.execSQL(db,delSql);</span><br><span class="line">    db.close();</span><br><span class="line">    break;</span><br><span class="line"> &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">&lt;Button</span><br><span class="line">  android:id=&quot;@+id/btn_insertApi&quot;</span><br><span class="line">  android:layout_width=&quot;wrap_content&quot;</span><br><span class="line">  android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">  android:text=&quot;插入数据&quot;</span><br><span class="line">  android:onClick=&quot;onclick&quot;</span><br><span class="line">  android:layout_marginTop=&quot;15dp&quot;</span><br><span class="line">  android:background=&quot;#000000&quot;/&gt;</span><br><span class="line">&lt;Button</span><br><span class="line">  android:id=&quot;@+id/btn_updateApi&quot;</span><br><span class="line">  android:layout_width=&quot;wrap_content&quot;</span><br><span class="line">  android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">  android:text=&quot;更新数据&quot;</span><br><span class="line">  android:onClick=&quot;onclick&quot;</span><br><span class="line">  android:layout_marginTop=&quot;15dp&quot;</span><br><span class="line">  android:background=&quot;#000000&quot;/&gt;</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line">public void onClick(View view)&#123;</span><br><span class="line">  switch(view.getId())&#123;</span><br><span class="line">   case R.id.btn_insertApi:</span><br><span class="line">    SQLiteDatabase db=helper.getWritableDatabase();</span><br><span class="line">    ContentValues values=new ContentValues();</span><br><span class="line">    values.put(Constant._ID,3);</span><br><span class="line">    values.put(Constant.NAME,&quot;vic&quot;);</span><br><span class="line">    values.put(Constant.AGE,17);</span><br><span class="line">    long result=db.insert(Constant.TABLE_NAME,null,values);</span><br><span class="line">    if(result&gt;0)&#123;</span><br><span class="line">     Toast.makeText(MainActivity.this,&quot;插入数据成功!&quot;,Toast.LENGTH_LONG).show();</span><br><span class="line">    &#125;else&#123;</span><br><span class="line">      Toast.makeText(MainActivity.this,&quot;插入数据失败!&quot;,Toast.LENGTH_LONG).show();</span><br><span class="line">    &#125;</span><br><span class="line">    db.close();</span><br><span class="line">    break;</span><br><span class="line">   case R.id.btn_updateApi:</span><br><span class="line">    //String table 修改的数据表的名称,ContentValues values,String whereClause 表示修改条件,String[] whereArgs</span><br><span class="line">    db=helper.getWritableDatabase();</span><br><span class="line">    //db.update(String table,ContentValues values,String whereClause,String[] whereArgs);</span><br><span class="line">    ContentValues cv=new ContentValues();</span><br><span class="line">    cv.put(Contant.NAME,&quot;vic3&quot;);</span><br><span class="line">    int count=db.update(Constant.TABLE_NAME,cv,Contant.TABLE_NAME,cv,Constant._ID+&quot;=?&quot;,new String[]&#123;&quot;3&quot;&#125;);</span><br><span class="line">    if(count&gt;0)&#123;</span><br><span class="line">     Toast.makeText(MainActivity.this,&quot;插入数据成功!&quot;,Toast.LENGTH_LONG).show();</span><br><span class="line">    &#125;else&#123;</span><br><span class="line">      Toast.makeText(MainActivity.this,&quot;插入数据失败!&quot;,Toast.LENGTH_LONG).show();</span><br><span class="line">    &#125;</span><br><span class="line">    db.close();</span><br><span class="line">    break;</span><br><span class="line">   &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">&lt;Button</span><br><span class="line">  android:id=&quot;@+id/btn_updateApi&quot;</span><br><span class="line">  android:layout_width=&quot;wrap_content&quot;</span><br><span class="line">  android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">  android:text=&quot;更新数据&quot;</span><br><span class="line">  android:onClick=&quot;onclick&quot;</span><br><span class="line">  android:layout_marginTop=&quot;15dp&quot;</span><br><span class="line">  android:background=&quot;#000000&quot;/&gt;</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><span class="line">public void onClick(View view)&#123;</span><br><span class="line">  switch(view.getId())&#123;</span><br><span class="line">   case R.id.btn_insertApi:</span><br><span class="line">    SQLiteDatabase db=helper.getWritableDatabase();</span><br><span class="line">    ContentValues values=new ContentValues();</span><br><span class="line">    values.put(Constant._ID,3);</span><br><span class="line">    values.put(Constant.NAME,&quot;vic&quot;);</span><br><span class="line">    values.put(Constant.AGE,17);</span><br><span class="line">    long result=db.insert(Constant.TABLE_NAME,null,values);</span><br><span class="line">    if(result&gt;0)&#123;</span><br><span class="line">     Toast.makeText(MainActivity.this,&quot;插入数据成功!&quot;,Toast.LENGTH_LONG).show();</span><br><span class="line">    &#125;else&#123;</span><br><span class="line">      Toast.makeText(MainActivity.this,&quot;插入数据失败!&quot;,Toast.LENGTH_LONG).show();</span><br><span class="line">    &#125;</span><br><span class="line">    db.close();</span><br><span class="line">    break;</span><br><span class="line">   case R.id.btn_updateApi:</span><br><span class="line">    //String table 修改的数据表的名称,ContentValues values,String whereClause 表示修改条件,String[] whereArgs</span><br><span class="line">    db=helper.getWritableDatabase();</span><br><span class="line">    //db.update(String table,ContentValues values,String whereClause,String[] whereArgs);</span><br><span class="line">    ContentValues cv=new ContentValues();</span><br><span class="line">    cv.put(Contant.NAME,&quot;vic3&quot;);</span><br><span class="line">    int count=db.update(Constant.TABLE_NAME,cv,Contant.TABLE_NAME,cv,Constant._ID+&quot;=?&quot;,new String[]&#123;&quot;3&quot;&#125;);</span><br><span class="line">    if(count&gt;0)&#123;</span><br><span class="line">     Toast.makeText(MainActivity.this,&quot;插入数据成功!&quot;,Toast.LENGTH_LONG).show();</span><br><span class="line">    &#125;else&#123;</span><br><span class="line">      Toast.makeText(MainActivity.this,&quot;插入数据失败!&quot;,Toast.LENGTH_LONG).show();</span><br><span class="line">    &#125;</span><br><span class="line">    db.close();</span><br><span class="line">    break;</span><br><span class="line">  case R.id.btn_deleteApi:</span><br><span class="line">  db=helper.getWritableDatabase();</span><br><span class="line"></span><br><span class="line">  //int count2=db.delete(String table,StringwhereClause,String[] whereArgs);</span><br><span class="line">  int count2=db.delete(Constant.TABLE_NAME,Constant._ID+&quot;=?&quot;,new String[]&#123;&quot;1&quot;&#125;);</span><br><span class="line">  if(count2&gt;0)&#123;</span><br><span class="line">     Toast.makeText(MainActivity.this,&quot;插入数据成功!&quot;,Toast.LENGTH_LONG).show();</span><br><span class="line">    &#125;else&#123;</span><br><span class="line">      Toast.makeText(MainActivity.this,&quot;插入数据失败!&quot;,Toast.LENGTH_LONG).show();</span><br><span class="line">    &#125;</span><br><span class="line">  db.close();</span><br><span class="line">  break;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"> public int delete(String table,String whereClause,String[] whereArgs)&#123;</span><br><span class="line">  acquireReference();</span><br><span class="line">  try&#123;</span><br><span class="line">   SQLiteStatement statement = new SQLiteStatement(this,&quot;DELETE FROM &quot;+table+(!TextUtils.isEmpty(whereClause) ? &quot; WHERE &quot;+whereClause : &quot;&quot;), whereArgs;</span><br><span class="line"> try&#123;</span><br><span class="line">  return statement.executeUpdateDelete();</span><br><span class="line">  &#125;finally&#123;</span><br><span class="line">   statement.close();</span><br><span class="line">  &#125;</span><br><span class="line">  &#125;finally&#123;</span><br><span class="line">  releaseReference();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h2><ul>
<li>本文讲了Android开发工程师文集-1 小时学会SQLite，如果您还有更好地理解，欢迎沟通</li>
<li>定位：分享 <code>Android</code>&amp;<code>Java</code>知识点，有兴趣可以继续关注</li>
</ul>
      
    </div>
    
    
    

      <div>
        
          <div>
    
        <div style="text-align:center;color: #ccc;font-size:14px">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
    
</div>
        
      </div>

    

      <div>
        <div id="wechat_subscriber" style="display: block; padding: 10px 0; margin: 20px auto; width: 100%; text-align: center">
    <img id="wechat_subscriber_qcode" src="/images/微信公众号.jpg" alt="达叔小生 wechat" style="width: 200px; max-width: 100%">
    <div>欢迎您扫一扫上面的微信公众号，订阅我的博客！</div>
</div>

      </div>
    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center">
  <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/images/wechatpay.png" alt="达叔小生 微信支付">
        <p>微信支付</p>
      </div>
    

    

    

  </div>
</div>

      </div>
    

    
      <div>
        <ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者：</strong>
    达叔小生
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="https://huangguangda.github.io/2018/03/16/1/" title="Android开发工程师文集-1 小时学会SQLite">https://huangguangda.github.io/2018/03/16/1/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>
    本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/3.0/" rel="external nofollow" target="_blank">CC BY-NC-SA 3.0</a> 许可协议。转载请注明出处！
  </li>
</ul>

      </div>
    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Android开发工程师文集/" rel="tag"><i class="fa fa-tag"></i> Android开发工程师文集</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/03/15/1/" rel="next" title="Android开发的插件Code Generator与LayoutCreator的安装与使用,提升你的开发效率">
                <i class="fa fa-chevron-left"></i> Android开发的插件Code Generator与LayoutCreator的安装与使用,提升你的开发效率
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/03/17/1/" rel="prev" title="Android开发工程师文集-1 小时学会各种Drawable">
                Android开发工程师文集-1 小时学会各种Drawable <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
        
<script>
  with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='//bdimg.share.baidu.com/static/api/js/share.js?cdnversion='+~(-new Date()/36e5)];
</script>

      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
      <div id="lv-container" data-id="city" data-uid="MTAyMC8zNTU5OC8xMjEzNA=="></div>
    </div>

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
      <div id="sidebar-dimmer"></div>
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/images/avatar.gif" alt="达叔小生">
            
              <p class="site-author-name" itemprop="name">达叔小生</p>
              <p class="site-description motion-element" itemprop="description"></p>

            <div id="days"></div>
<script>
function show_date_time(){
window.setTimeout("show_date_time()", 1000);
BirthDay=new Date("04/23/1997 00:00:00");
today=new Date();
timeold=(today.getTime()-BirthDay.getTime());
sectimeold=timeold/1000
secondsold=Math.floor(sectimeold);
msPerDay=24*60*60*1000
e_daysold=timeold/msPerDay
daysold=Math.floor(e_daysold);
e_hrsold=(e_daysold-daysold)*24;
hrsold=setzero(Math.floor(e_hrsold));
e_minsold=(e_hrsold-hrsold)*60;
minsold=setzero(Math.floor((e_hrsold-hrsold)*60));
seconds=setzero(Math.floor((e_minsold-minsold)*60));
document.getElementById('days').innerHTML="已运行"+daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒";
}
function setzero(i){
if (i<10)
{i="0" + i};
return i;
}
show_date_time();
</script>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives">
              
                  <span class="site-state-item-count">94</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">20</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">21</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
                <a title="收藏到书签，偶尔High一下^_^" rel="alternate" class="mw-harlem_shake_slow wobble shake" href="javascript:(function() {
    function c() {
        var e = document.createElement(&quot;link&quot;);
        e.setAttribute(&quot;type&quot;, &quot;text/css&quot;);
        e.setAttribute(&quot;rel&quot;, &quot;stylesheet&quot;);
        e.setAttribute(&quot;href&quot;, f);
        e.setAttribute(&quot;class&quot;, l);
        document.body.appendChild(e)
    }
 
    function h() {
        var e = document.getElementsByClassName(l);
        for (var t = 0; t < e.length; t++) {
            document.body.removeChild(e[t])
        }
    }
 
    function p() {
        var e = document.createElement(&quot;div&quot;);
        e.setAttribute(&quot;class&quot;, a);
        document.body.appendChild(e);
        setTimeout(function() {
            document.body.removeChild(e)
        }, 100)
    }
 
    function d(e) {
        return {
            height : e.offsetHeight,
            width : e.offsetWidth
        }
    }
 
    function v(i) {
        var s = d(i);
        return s.height > e && s.height < n && s.width > t && s.width < r
    }
 
    function m(e) {
        var t = e;
        var n = 0;
        while (!!t) {
            n += t.offsetTop;
            t = t.offsetParent
        }
        return n
    }
 
    function g() {
        var e = document.documentElement;
        if (!!window.innerWidth) {
            return window.innerHeight
        } else if (e && !isNaN(e.clientHeight)) {
            return e.clientHeight
        }
        return 0
    }
 
    function y() {
        if (window.pageYOffset) {
            return window.pageYOffset
        }
        return Math.max(document.documentElement.scrollTop, document.body.scrollTop)
    }
 
    function E(e) {
        var t = m(e);
        return t >= w && t <= b + w
    }
 
    function S() {
        var e = document.createElement(&quot;audio&quot;);
        e.setAttribute(&quot;class&quot;, l);
        e.src = i;
        e.loop = false;
        e.addEventListener(&quot;canplay&quot;, function() {
            setTimeout(function() {
                x(k)
            }, 500);
            setTimeout(function() {
                N();
                p();
                for (var e = 0; e < O.length; e++) {
                    T(O[e])
                }
            }, 15500)
        }, true);
        e.addEventListener(&quot;ended&quot;, function() {
            N();
            h()
        }, true);
        e.innerHTML = &quot; <p>If you are reading this, it is because your browser does not support the audio element. We recommend that you get a new browser.</p> <p>&quot;;
        document.body.appendChild(e);
        e.play()
    }
 
    function x(e) {
        e.className += &quot; &quot; + s + &quot; &quot; + o
    }
 
    function T(e) {
        e.className += &quot; &quot; + s + &quot; &quot; + u[Math.floor(Math.random() * u.length)]
    }
 
    function N() {
        var e = document.getElementsByClassName(s);
        var t = new RegExp(&quot;\\b&quot; + s + &quot;\\b&quot;);
        for (var n = 0; n < e.length; ) {
            e[n].className = e[n].className.replace(t, &quot;&quot;)
        }
    }
 
    var e = 30;
    var t = 30;
    var n = 350;
    var r = 350;
    var i = &quot;//s3.amazonaws.com/moovweb-marketing/playground/harlem-shake.mp3&quot;;
    var s = &quot;mw-harlem_shake_me&quot;;
    var o = &quot;im_first&quot;;
    var u = [&quot;im_drunk&quot;, &quot;im_baked&quot;, &quot;im_trippin&quot;, &quot;im_blown&quot;];
    var a = &quot;mw-strobe_light&quot;;
    var f = &quot;//s3.amazonaws.com/moovweb-marketing/playground/harlem-shake-style.css&quot;;
    var l = &quot;mw_added_css&quot;;
    var b = g();
    var w = y();
    var C = document.getElementsByTagName(&quot;*&quot;);
    var k = null;
    for (var L = 0; L < C.length; L++) {
        var A = C[L];
        if (v(A)) {
            if (E(A)) {
                k = A;
                break
            }
        }
    }
    if (A === null) {
        console.warn(&quot;Could not find a node of the right size. Please try a different page.&quot;);
        return
    }
    c();
    S();
    var O = [];
    for (var L = 0; L < C.length; L++) {
        var A = C[L];
        if (v(A)) {
            O.push(A)
        }
    }
})()"><i class="fa fa-music"></i> High</a>

            </div>
          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/huangguangda" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="mailto:2397923107@qq.com" target="_blank" title="E-Mail">
                      
                        <i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://www.jianshu.com/u/c785ece603d1" target="_blank" title="简书">
                      
                        <i class="fa fa-fw fa-android"></i>简书</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://blog.csdn.net/qq_36232611" target="_blank" title="csdn">
                      
                        <i class="fa fa-fw fa-spinner"></i>csdn</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://www.douban.com/people/186539024/" target="_blank" title="豆瓣">
                      
                        <i class="fa fa-fw fa-bath"></i>豆瓣</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://www.zhihu.com/people/da-shu-xiao-sheng/activities" target="_blank" title="知乎">
                      
                        <i class="fa fa-fw fa-globe"></i>知乎</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://juejin.im/user/5a16e1f3f265da43128096cb" target="_blank" title="掘金">
                      
                        <i class="fa fa-fw fa-google"></i>掘金</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://weibo.com/5507262458/profile?topnav=1&wvr=6" target="_blank" title="微博">
                      
                        <i class="fa fa-fw fa-weibo"></i>微博</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzI1NTcxOTQ1Nw==&scene=124#wechat_redirect" target="_blank" title="历史">
                      
                        <i class="fa fa-fw fa-apple"></i>历史</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="http://www.cnblogs.com/dashucoding/" target="_blank" title="博客园">
                      
                        <i class="fa fa-fw fa-facebook"></i>博客园</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://gdone.gitee.io/englishpages/index.html" target="_blank" title="英文简历">
                      
                        <i class="fa fa-fw fa-globe"></i>英文简历</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://gdone.gitee.io/pages/" target="_blank" title="中文简历">
                      
                        <i class="fa fa-fw fa-heartbeat"></i>中文简历</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://gitee.com/GDone/events" target="_blank" title="码云">
                      
                        <i class="fa fa-fw fa-twitter"></i>码云</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://my.oschina.net/xiaomaomi1997/" target="_blank" title="开源中国">
                      
                        <i class="fa fa-fw fa-facebook"></i>开源中国</a>
                  </span>
                
            </div>
          

          
          
            <div class="cc-license motion-element" itemprop="license">
              <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" class="cc-opacity" target="_blank">
                <img src="/images/cc-by-nc-sa.svg" alt="Creative Commons">
              </a>
            </div>
          

          
          
            <div class="links-of-blogroll motion-element links-of-blogroll-inline">
              <div class="links-of-blogroll-title">
                <i class="fa fa-fw fa-globe"></i>
                推荐阅读
              </div>
              <ul class="links-of-blogroll-list">
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.alloyteam.com/nav/" title="Web前端导航" target="_blank">Web前端导航</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.36zhen.com/t?id=3448" title="前端书籍资料" target="_blank">前端书籍资料</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://ife.baidu.com/" title="百度前端技术学院" target="_blank">百度前端技术学院</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://wf.uisdc.com/cn/" title="google前端开发基础" target="_blank">google前端开发基础</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.geekbang.org/" title="极客邦科技" target="_blank">极客邦科技</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://ilxdh.com/" title="龙轩导航" target="_blank">龙轩导航</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://code.giffox.com/" title="程序员导航" target="_blank">程序员导航</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://search.chongbuluo.com/" title="快搜" target="_blank">快搜</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.android-doc.com/training/index.html" title="Android中文API" target="_blank">Android中文API</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://developer.android.google.cn/" title="Android Developers" target="_blank">Android Developers</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.freecodecamp.cn/" title="FreeCodeCamp中文社区" target="_blank">FreeCodeCamp中文社区</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://docs.oracle.com/javase/specs/" title="Java SE规范" target="_blank">Java SE规范</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://liuwangshu.cn/" title="刘望舒" target="_blank">刘望舒</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.colabug.com/author/3159ee71c93b3b4a/" title="小楼昨夜又秋风" target="_blank">小楼昨夜又秋风</a>
                  </li>
                
              </ul>

            </div>
          


        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#前言"><span class="nav-number">1.</span> <span class="nav-text">前言</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#内容"><span class="nav-number">1.1.</span> <span class="nav-text">内容</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#内容-1"><span class="nav-number">1.2.</span> <span class="nav-text">内容</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#要点"><span class="nav-number">1.3.</span> <span class="nav-text">要点</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#总结"><span class="nav-number">1.4.</span> <span class="nav-text">总结</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love" id="heart">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">达叔小生</span>

  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
      <span class="post-meta-item-text">Site words total count&#58;</span>
    
    <span title="Site words total count">357.6k</span>
  
</div>






  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Mist</a> v5.1.4</div>




<div class="theme-info">
  <div class="powered-by"></div>
  <span class="post-count">博客全站共357.6k字</span>
</div>

<div class="weixin-box">
  <div class="weixin-menu">
    <div class="weixin-hover">
      <div class="weixin-description">微信扫一扫，订阅本博客</div>
    </div>
  </div>
</div>
        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user">本站访客数</i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye">本站总访问量</i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      次
    </span>
  
</div>





  <script type="text/javascript">
    (function() {
      var hm = document.createElement("script");
      hm.src = "//tajs.qq.com/stats?sId=65809965";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
          <span id="scrollpercent"><span>0</span>%</span>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  



  
  









  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>
  

  
  
    <script type="text/javascript" src="/lib/three/three.min.js"></script>
  

  
  
    <script type="text/javascript" src="/lib/three/three-waves.min.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  
    <script type="text/javascript">
      (function(d, s) {
        var j, e = d.getElementsByTagName(s)[0];
        if (typeof LivereTower === 'function') { return; }
        j = d.createElement(s);
        j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
        j.async = true;
        e.parentNode.insertBefore(j, e);
      })(document, 'script');
    </script>
  












  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  
  

  
  
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script type="text/javascript" src="//cdn.bootcss.com/mathjax/2.7.1/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
  


  

  


  <script type="text/javascript" src="/lib/clipboard/clipboard.min.js"></script>
<script type="text/javascript" src="/js/src/custom.js"></script>


   <canvas class="fireworks" style="position: fixed;left: 0;top: 0;z-index: 1; pointer-events: none"></canvas> 
   <script type="text/javascript" src="//cdn.bootcss.com/animejs/2.2.0/anime.min.js"></script> 
   <script type="text/javascript" src="/js/src/fireworks.js"></script>


  <!-- 代码块复制功能 -->
  <script type="text/javascript" src="/js/src/clipboard.min.js"></script>  
  <script type="text/javascript" src="/js/src/clipboard-use.js"></script>
<script src="/live2dw/lib/L2Dwidget.min.js?0c58a1486de42ac6cc1c59c7d98ae887"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"live2d-widget-model-hibiki"},"display":{"position":"right","width":75,"height":150},"mobile":{"show":false},"log":false});</script></body>
</html>